﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class Buy : System.Web.UI.Page
{
    public string time;
    protected DataTable Datascp = null;

    protected DataTable Datahemai = null;
    protected DataTable Dataallzgje = null;
    protected string css = string.Empty;
    protected DataTable Dataallje = null;

    public string cptype;
    public Int64 jine;
    public Int64 a;
    public Int64 b;
    public Int64 c;
    public string yi;
    public string wan;
    public string yuan;

    protected void Page_Load(object sender, EventArgs e)
    {
        cptype = Request["t"];
        time = DateTime.Now.ToString("yyyy-MM-dd");

        alljine();
        DataCentercp();

    }
    private void alljine()//双色球
    {
        string sql = " select LotteryChipped.LotteryOpenTime,isnull(sum(LotteryChipped.WinMoney),0)  as alljine from LotteryChipped  where LotteryChipped.LotteryType=" + cptype + "  group by  LotteryChipped.LotteryOpenTime order by LotteryOpenTime  desc";
        Dataallje = BLL.LotteryChipped.GetPageListBysql(sql);
        string sqll = "select LotteryBuyDetail.LotteryQs,isnull(sum([LotteryBuyDetail].WinMoney),0)  as alljine from [LotteryBuyDetail]  where LotteryBuyDetail.LotteryType=" + cptype + "  group by  LotteryBuyDetail.LotteryQs order by LotteryQs  desc";
        Dataallzgje = BLL.LotteryBuyDetail.GetPageListBysql(sqll);

        if (Dataallje.Rows.Count > 0 && Dataallzgje.Rows.Count > 0)
        {
            jine = Convert.ToInt64(Dataallje.Rows[0]["alljine"]) + Convert.ToInt64(Dataallzgje.Rows[0]["alljine"]);
        }
        else if (Dataallje.Rows.Count == 0)
        {
            jine = Convert.ToInt64(Dataallzgje.Rows[0]["alljine"]);
        }
        else if (Dataallzgje.Rows.Count == 0)
        {
            jine = Convert.ToInt64(Dataallje.Rows[0]["alljine"]);
        }


        if (jine > 99999999)
        {

            a = Convert.ToInt64(jine) / 100000000;
            yi = a + "亿";
            jine = jine - a * 100000000;
        }
        if (jine > 9999)
        {
            b = Convert.ToInt64(jine) / 10000;
            wan = b + "万";
            jine = jine - b * 10000;
        }
        if (jine < 10000)
        {

            c = Convert.ToInt64(jine);
            if (c < 1000)
            {
                yuan = "0" + c + "元";
            }
            if (c == 0)
            {
                yuan = null;
            }
            else
            {
                yuan = c + "元";

            }

        }

    }
    protected void qsSelectedIndexChanged(object sender, EventArgs e)
    {
        if (qsDropDownList.SelectedValue == "1")
        {
            Response.Redirect("DataCenterDetail.aspx?t=1");

        }
        if (qsDropDownList.SelectedValue == "2")
        {
            Response.Redirect("DataCenterDetail.aspx?t=2");

        }
        if (qsDropDownList.SelectedValue == "3")
        {
            Response.Redirect("DataCenterDetail.aspx?t=3");

        }
        if (qsDropDownList.SelectedValue == "4")
        {
            Response.Redirect("DataCenterDetail.aspx?t=4");

        }
        if (qsDropDownList.SelectedValue == "5")
        {
            Response.Redirect("DataCenterDetail.aspx?t=5");

        }
        if (qsDropDownList.SelectedValue == "6")
        {
            Response.Redirect("DataCenterDetail.aspx?t=6");

        }
        if (qsDropDownList.SelectedValue == "7")
        {
            Response.Redirect("DataCenterDetail.aspx?t=7");

        }
    }

    private void DataCentercp()//合买
    {

        string sqlstr = @"select  CMember.nickname,LotteryAnnouncement.openTime ,
                        [LotteryChipped].[LotteryOpenTime],[dbo].[LotteryChipped].WinMoney,[LotteryChipped].MySub  
                        from [dbo].CMember,LotteryAnnouncement,[LotteryChipped]
                        where  CMember.Id=[LotteryChipped].UserID  and 
                        [dbo].[LotteryAnnouncement].LotteryQS = [LotteryChipped].LotteryOpenTime and [LotteryChipped].LotteryType=" + cptype + " and IsWin=1 ORDER BY [LotteryOpenTime] DESC  ";
        Datascp = BLL.LotteryChipped.GetPageListBysql(sqlstr);


    }


}